package com.oceansoft.mobile.econsole.modules.api.controller;

import com.alibaba.fastjson.JSONObject;
import com.oceansoft.mobile.econsole.common.constant.Constant;
import com.oceansoft.mobile.econsole.common.util.StringUtils;
import com.oceansoft.mobile.econsole.modules.api.entity.CarType;
import com.oceansoft.mobile.econsole.modules.api.service.IQueryService;
import com.oceansoft.mobile.econsole.modules.base.entity.Result;
import com.oceansoft.mobile.econsole.modules.jlapi.entity.InQueryServiceInfo;
import com.oceansoft.mobile.econsole.modules.jlapi.entity.OutQueryServiceInfo;
import com.oceansoft.mobile.econsole.modules.jlapi.service.IJlApiService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import java.util.List;

import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;

/**
 * 城市服务相关接口
 *
 * @author: huqp
 * @time: 2016-4-25 0022 上午 10:30
 */
@Controller
@RequestMapping("api/cityservice")
public class ApiCityServiceController {

    @Resource
    private IQueryService queryService;

    /**
     * 加载车辆类型列表
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "vehicle/cartype", method = GET)
    public Result loadWtCarTypeList(){

        return queryService.loadWtCarTypeList(Constant.JDCHPZL);
    }

    /**
     * 机动车违法查询
     * 外部调用API
     *
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "car/illegal", method = POST)
    public Result carIllegalQuery(HttpServletRequest request) {

        return queryService.loadcarIllegalList(request);
    }

    /**
     * 驾驶证记分查询
     * 外部调用API
     *
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "driver/points", method = POST)
    public Result driverPointsQuery(HttpServletRequest request) {

        return queryService.loadDriverPointsInfo(request);
    }

    /**
     * 重名查询
     * 外部调用API
     *
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "name/repeat", method = POST)
    public Result nameRepeatQuery(HttpServletRequest request) {

        return queryService.loadNameRepeatQuery(request);
    }

    /**
     * 获取内外网查询消息结果
     *
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "result/gain", method = POST)
    public Result queryResultGain(HttpServletRequest request) {
        String action = request.getParameter("action");
        if(StringUtils.isBlank(action)){
            return new Result(Result.FAILURE,Constant.STATUS_CODE_100199,null,"请输入查询接口类别");
        }
        String command = request.getParameter("command");
        if(StringUtils.isBlank(command)){
            return new Result(Result.FAILURE,Constant.STATUS_CODE_100199,null,"请输入查询条件");
        }

        return queryService.queryResultGain(action,command);
    }

}
